package com.mindcare.domain;

import com.mindcare.constant.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private Integer code;
    private T data;
    private String message;

    public static <T> Result<T> success(T data){
        return new Result<T>(ResultCode.SUCCESS,data,"成功");
    }

    public static <T> Result<T> success(){
        return new Result<T>(ResultCode.SUCCESS,null,"成功");
    }

    public static <T> Result<T> fail(T data,String message){
        return new Result<T>(ResultCode.ERROR,data,message);
    }

    public static <T> Result<T> fail(Integer code,T data,String message){
        return new Result<T>(code,data,message);
    }
}
